<template>
  <view class="content">
    <view class="status_bar"></view>

    <view class="main">
      <view class="main_top">
        <image
          src="../../static/jiantous.png"
          mode=""
          class="main_top_img"
          @click="handleBack"
        ></image>

        <view class="main_top_text">积分</view>
      </view>

      <view class="main_price">
        <image
          src="../../static/jifen_icon.png"
          mode=""
          class="main_price_img"
        ></image>
        文创积分</view
      >
      <view class="main_num">{{
        walletDetail ? walletDetail.wc_point : 0
      }}</view>

      <view class="main_notice">-累计获得积分-</view>

      <view class="main_line"></view>

      <view class="main_bottom">
        <view class="main_item" @click="handleSort(0)">
          <view
            class="main_item_text"
            :class="now_check == 0 ? 'main_item_active' : ''"
            >全部</view
          >
        </view>

        <view class="main_item" @click="handleSort(1)">
          <view
            class="main_item_text"
            :class="now_check == 1 ? 'main_item_active' : ''"
            >收入</view
          >
        </view>

        <view class="main_item" @click="handleSort(2)">
          <view
            class="main_item_text"
            :class="now_check == 2 ? 'main_item_active' : ''"
            >支出</view
          >
        </view>
      </view>
    </view>

    <view class="information_wrapper">
      <view class="information" v-for="(item, index) in pointLogList">
        <view class="information_left">
          <view class="information_left_row1">{{ item.remark }}</view>
          <view class="information_left_row2">{{ item.created_at }}</view>
        </view>
        <view class="information_right">{{ item.change }}</view>
      </view>
    </view>

    <view class="transfer_button" @click="tozhuanzahng">
      转账给好友
    </view>

    <empty :show.sync="pointLogList.length == 0 && is_done"></empty>

    <!-- <view class="detail">
      <view class="detail_title">提现说明</view>
      <u-parse :html="walllestext" style="color: #ffffff"></u-parse>
    </view> -->

    <!-- <view class="fixed">
      <view class="fixed_button" @click="toJump">转账到积分商城</view>
    </view> -->
  </view>
</template>

<script>
import api from "@/api/api.js";
import tip from "@/utils/tip.js";
import empty from "@/components/empty/empty";
export default {
  components: {
    empty,
  },
  data() {
    return {
      walletDetail: null,

      price: "",
      walllestext: null,
      pointLogList: [],
      page: 1,
      now_check: 0,
      is_done: false,
    };
  },
  onLoad(options) {
    // this.getRuletext();
  },
  onShow() {
    this.getuserWallet();
    this.getPointLog(true);
  },
  // 页面的触底事件
  onReachBottom() {
    this.page++;
    this.$u.throttle(this.getPointLog(), 1000, true);
  },
  methods: {
    tozhuanzahng(){
      uni.navigateTo({
        //1积分
        url: `../shandeWallet/shandeTransfer?type=1`,
      });
    },
    handleBack() {
      uni.navigateBack({
        delta: 1,
      });
    },

    async getuserWallet() {
      let res = await api.userWallet({ method: "get", loading: "加载中" });

      if (res.code === 0) {
        this.walletDetail = res.data;
      } else {
        tip.defaults(res.msg);
      }
    },

    handleSort(index) {
      this.now_check = index;
      if (index == 0) {
        this.getPointLog(true);
      } else if (index == 1) {
        this.getPointLog(true);
      } else if (index == 2) {
        this.getPointLog(true);
      }
    },

    async getPointLog(refresh) {
      if (refresh) {
        this.page = 1;
      }

      let res = await api.wcPointLog({
        method: "get",
        query: {
          is_payout: this.now_check == 1 ? 0 : this.now_check == 2 ? 1 : "",
        },
        loading: "加载中",
      });

      if (res.code === 0) {
        this.is_done = true;
        if (refresh) {
          this.pointLogList = res.data;
        } else {
          this.pointLogList = this.pointLogList.concat(res.data);
        }
      } else {
        tip.defaults(res.msg);
      }
    },

    async getRuletext() {
      // let res = await api.getRule({
      //   method: "get",
      //   query: { key: "cash_out_rule" },
      //   loading: "加载中",
      // });
      // console.log(res, "res");
      // this.walllestext = res.data ? res.data.value : "";
    },
    // toJump() {
    //   uni.navigateTo({
    //     url: "../pointTransfer/pointTransfer",
    //   });
    // },
  },
};
</script>

<style lang="scss" scoped>
@import "../../style/yuanchuang.scss";
.content {
  font-family: PingFangSC-Regular, PingFang SC;
  padding: 0 30rpx 100rpx 30rpx;
  background: $bg-color1;

  min-height: 100vh;
}
.status_bar {
  margin: 0 -30rpx;
  height: var(--status-bar-height);
  width: 750rpx;
}
.main {
  margin: 0 -30rpx;
  padding: 0 30rpx;
  height: 412rpx;
  background-image: url(../../static/integral_bg.png);
  background-repeat: no-repeat;
  background-size: 100%;
  &_top {
    margin-left: -30rpx;
    position: relative;
    display: flex;

    width: 750rpx;
    height: 88rpx;
    &_img {
      position: absolute;
      left: 30rpx;
      top: 23rpx;
      width: 42rpx;
      height: 42rpx;
    }
    &_text {
      margin: 0 auto;
      width: 68rpx;
      height: 88rpx;
      font-size: 34rpx;
      font-weight: 500;
      color: #ffffff;
      line-height: 88rpx;
    }
  }
  &_price {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 30rpx auto 0;
    // width: 128rpx;
    height: 44rpx;
    font-size: 32rx;
    font-weight: 400;
    color: #ffffff;
    line-height: 44rpx;
    text-align: center;
    &_img {
      margin-right: 14rpx;
      width: 32rpx;
      height: 32rpx;
    }
  }
  &_num {
    margin-top: 14rpx;
    // width: 204rpx;
    height: 86rpx;
    // font-size: 44rpx;
    font-size: 72rpx;
    font-weight: bold;
    color: #ffffff;
    line-height: 86rpx;
    text-align: center;
  }
  &_notice {
    margin-top: 10rpx;
    // width: 174rpx;
    height: 34rpx;
    font-size: 24rpx;
    font-weight: 400;
    color: #ffffff;
    line-height: 34rpx;
    text-align: center;
  }
  &_line {
    margin-top: 40rpx;
    width: 750rpx;
    height: 2rpx;
    background: #d8d8d8;
    opacity: 0.18;
  }
  &_bottom {
    // padding: 28rpx 0 0 0;
    margin: 0 -30rpx;
    height: 104rpx;
    // padding: 24rpx 2rpx 0 2rpx;
    padding: 0 2rpx 0 2rpx;
    display: flex;
    align-items: center;
    background: #292b2b;
  }
  &_item {
    // padding: 0 48rpx;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    // text-align: center;
    &_img {
      width: 32rpx;
      height: 32rpx;
    }
    &_text {
      margin-left: 6rpx;
      // width: 56rpx;
      height: 40rpx;
      font-size: 28rpx;
      font-weight: 400;
      color: #cccccc;
      line-height: 40rpx;
    }
    &_active {
      color: $text-color3;
    }
  }
  &_item:not(:first-child) {
    border-left: 2rpx solid #404040;
  }
}
.title {
  height: 40rpx;
  font-size: 28rpx;
  font-weight: 400;
  color: #0c1125;
  line-height: 40rpx;
}
.record {
  margin-top: 30rpx;
  display: flex;
  align-items: center;
  width: 690rpx;
  height: 242rpx;
  border-radius: 24rpx;
  background-image: url(../../static/wallet_background.png);
  background-repeat: no-repeat;
  background-size: 100% 242rpx;
  display: flex;
  justify-content: space-between;
  position: relative;
  .record_price {
    display: flex;
    flex-direction: column;
    margin: 30rpx;
    text {
      color: #ffffff;
      font-size: 16px;
      margin: 10rpx 0;
    }
    .record_price_text {
      margin: 10rpx 0;
      text:nth-child(2) {
        color: #ffffff;
        font-size: 24px;
        font-weight: bold;
      }
    }
  }
  .record_button {
    position: absolute;
    bottom: 30rpx;
    right: 15rpx;
    color: #ffffff;
    text {
      margin: 0 15rpx;
      border: 2rpx solid #ffffff;
      border-radius: 32rpx;
      padding: 8rpx 16rpx;
    }
  }
}
.price {
  margin-top: 30rpx;
  width: 100%;
  background: $bg-color3;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text {
    margin: 30rpx;
    color: $text-color1;
  }
  text:first-child {
    font-size: 16px;
  }
  text:nth-child(2) {
    font-size: 12px;
  }
  .price_input {
    height: 100rpx;
    display: flex;
    align-content: flex-start;
    input {
      height: 120rpx;
      line-height: 120rpx;
      color: $text-color1;
    }
    border-bottom: 2rpx solid #313535;
    text {
      font-size: 22px;
      font-weight: 500;
    }
  }
}
.listwhole {
  display: flex;
  align-content: center;
  justify-content: space-between;
  margin: 30rpx 0;
  padding: 30rpx;
  border-radius: 24rpx;
  background-color: $bg-color3;
  height: 150rpx;
  .list_new {
    color: $text-color1;
    margin: auto;
    .list_new_img {
      width: 24rpx;
      height: 24rpx;
      margin-right: 10rpx;
    }
  }
  .list_left {
    display: flex;
    .list_left_img {
      width: 80rpx;
      height: 80rpx;
    }
    .list_left_right {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      margin-left: 30rpx;
      color: $text-color1;
      font-size: 28rpx;
    }
  }
  .list_right_img {
    margin: auto 0;
    width: 30rpx;
    height: 30rpx;
    // margin-top: 15rpx;
  }
}

.button {
  margin-top: 50rpx;
  width: 690rpx;
  height: 90rpx;
  color: #ffffff;
  background: $button;
  background-repeat: no-repeat;
  // background-attachment: fixed;
  background-size: 100% 100%;
  border-radius: 16rpx;

  font-size: 32rpx;
  font-weight: 400;
  line-height: 90rpx;
  text-align: center;
}
.detail {
  margin-top: 70rpx;
  &_title {
    font-size: 30rpx;
    font-weight: 400;
    color: #ffffff;
    line-height: 40rpx;
    margin: 30rpx 0;
  }
  &_row {
    margin-top: 30rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #bbbbbe;
    line-height: 40rpx;
    white-space: break-spaces;
  }
  &_row + &_row {
    margin-top: 20rpx;
  }
}
.input_center {
  color: #ffffff;
  // height: 260rpx;
  // padding: 30rpx 0 0rpx;
  word-break: break-all;
  margin: 30rpx;
  max-height: 300rpx;
}
.Transaction_eject {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  height: 290rpx;
  background-color: #ffffff;
  .Transaction_top {
    font-size: 32rpx;
    color: #0c1125;
    margin-top: 50rpx;
  }
  .Transaction_center {
    padding: 0 20rpx;
    border: 2rpx solid #f6f8fa;
    background: #f6f8fa;
    border-radius: 16rpx;
    height: 85rpx;
    width: 80%;
    color: #0c1125;
  }
  .Transaction_bottom {
    font-size: 32rpx;
    color: #0144ef;
    margin-bottom: 30rpx;
  }
}
.pricemode {
  color: $text-color1;
  background-color: $bg-color3;
  display: flex;
  justify-content: space-between;
  padding: 30rpx;
  margin-top: 30rpx;
  image {
    margin: auto 0;
    width: 30rpx;
    height: 30rpx;
  }
  border-radius: 24rpx;
  font-size: 28rpx;
}
.information_wrapper {
  margin-top: 30rpx;
}
.transfer_button{
  position: fixed;
  bottom: 90rpx;
  left: 40rpx;
  right: 40rpx;
  height: 90rpx;
  background: linear-gradient(90deg, #1FE6E6 0%, #3F9ED2 48%, #DF7FD6 100%);
  text-align: center;
  line-height: 90rpx;
  border-radius: 60rpx 5rpx 60rpx 5rpx;
  color: #ffffff;
  font-size: 32rpx;
}
.information {
  padding: 30rpx 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2rpx solid #292b2b;
  &_left {
    &_row1 {
      // width: 192rpx;
      height: 44rpx;
      font-size: 32rpx;
      font-weight: 500;
      color: #ffffff;
      line-height: 44rpx;
    }
    &_row2 {
      margin-top: 8rpx;
      width: 242rpx;
      height: 34rpx;
      font-size: 24rpx;
      font-weight: 400;
      color: #999999;
      line-height: 34rpx;
    }
  }
  &_right {
    // width: 64rpx;
    height: 42rpx;
    font-size: 36rpx;
    font-weight: 600;
    color: #ffffff;
    line-height: 42rpx;
  }
}
// .information + .information {

// }
.fixed {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  width: 750rpx;
  height: 130rpx;
  background: #292b2b;
  &_button {
    width: 670rpx;
    height: 90rpx;
    margin: 20rpx auto 0;
    background: $button;
    background-repeat: no-repeat;
    background-size: 100%;

    font-size: 32rpx;
    font-weight: 400;
    color: #ffffff;
    line-height: 90rpx;
    text-align: center;
  }
}
</style>